<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>{$addon.info.name} {:lang('plugin.in_configuration')}</title>
    <link href="/static/admin/css/font_2321976_xoewfg91tpo.css" rel="stylesheet">
    <link href="/static/admin/css/bootstrap.min.css" rel="stylesheet">
    <link href="/static/admin/css/style.min.css" rel="stylesheet">
    <script type="text/javascript" src="/static/admin/js/jquery.min.js"></script>
    <script type="text/javascript" src="/static/admin/js/cookie.min.js"></script>
    <script type="text/javascript" src="/static/admin/js/wangEditor.min.js"></script>
    <style>
        body{background-color:#fff;}.lyear-layout-content{padding-top:0;}.card,.table-responsive{border:0;}.lyear-layout-content{padding-left:0;}.card-body{padding:0 10px;}.fieldlist dd ins{width:183px;display:inline-block;text-decoration:none;font-weight:bold;}.fieldlist dd{display:block;margin:5px 0;}.fieldlist dd input:first-child{width:35%;}.form-inline .form-control{display:inline-block;width:60%;vertical-align:middle;}.td-left{padding:20px 10px!important;}.btn-remove{padding:3px;cursor:pointer;background:#ff574b;color:#fff;font-weight:700;font-size:12px;border-radius:50%;margin-left:10px;}.btn-remove:hover{background:#ff1100;}#myform label{margin:7px 0 0 7px;}.iframe-footer{left:0px;padding-top:15px;padding-left:33px;position:fixed;bottom:0;width:100%;height:60px;margin-bottom:0;background:#e6e6e6;z-index: 99999;}
        .hidden-input{position:absolute;right:33%;top:0;z-index:1;height:30px;opacity:0;cursor:pointer;width:7%;}.faupload-preview{margin-top:15px;padding:0 10px;margin-bottom:0;}.btn-trash{display:block;}.thumbnail .btn-remove2{position:absolute;right:-25px;top:-5px;background:inherit;color:#000;font-size:19px;border-radius:50%;margin-left:10px;font-weight:700;padding:3px;cursor:pointer;}
        .editor_array input[type="text"] {
            width: 100%!important;
            margin-bottom: 15px;
        }
        .editor_array .btn-remove{
            position: relative;
            top: -20px;
            float: right;
            left: 25px;
            z-index: 99999;
            height: 19px;
            font-size: 11px;
            line-height: 14px;
        }
        .w-e-toolbar {
            padding:0;
            border-bottom:0!important;
        }
        .w-e-toolbar .w-e-menu {
            width: 23px;
            height: 25px;
        }
        .w-e-menu .w-e-panel-container .w-e-panel-tab-content textarea {
            height: 57px!important;
        }
    </style>
</head>
<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <main class="lyear-layout-content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="card">
                            <div class="card-body">
                                {if $addon.tips}
                                <div class="alert {$addon.tips.extend|default='alert-success'}" role="alert">
                                    <h4>{$addon.tips.title}</h4>
                                    <p>{$addon.tips.value}</p>
                                </div>
                                {/if}
                                <form id="myform" class="row">
                                    <div class="table-responsive col-md-12">
                                        <table class="table">
                                            <thead>
                                            <tr>
                                                <th width="15%">{:lang('title')}</th>
                                                <th width="85%">{:lang('plugin.value')}</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            {foreach :rewrite_addons_config($addon.info.name) as $item}
                                            <tr>
                                                <td class="td-left">{$item.title}</td>
                                                <td>
                                                    <div class="row">
                                                        <div class="col-sm-8 col-xs-12 plugin-config">
                                                            {switch $item.type}
                                                            {case string}
                                                            <input type="text" name="row[{$item.name}]" value="{$item.value|htmlentities}" class="form-control" form-verify="{$item.rule}" data-rule-msg="{$item.rule_msg}"/>
                                                            {/case}
                                                            {case text}
                                                            <textarea name="row[{$item.name}]" class="form-control" form-verify="{$item.rule}" rows="5" data-rule-msg="{$item.rule_msg}">{$item.value|htmlentities}</textarea>
                                                            {/case}
                                                            {case array}
                                                            <dl class="fieldlist" data-name="row[{$item.name}]">
                                                                <dd>
                                                                    <ins>{:lang('plugin.array_key')}</ins>
                                                                    <ins>{:lang('plugin.array_value')}</ins>
                                                                </dd>
                                                                {php}$item_index = 0;{/php}
                                                                {foreach $item.value as $key2=>$item2}
                                                                <dd class="form-inline">
                                                                    <input type="text" name="row[{$item.name}][{$item_index}][key]" form-verify="required" data-rule-msg="不能为空" class="form-control" value="{$key2}" size="10">
                                                                    <input type="text" name="row[{$item.name}][{$item_index}][value]" form-verify="{$item.rule}" data-rule-msg="{$item.rule_msg}" class="form-control" value="{$item2}">
                                                                    <i class="iconfont icon-iconset0127 btn-remove"></i>
                                                                </dd>
                                                                {php}$item_index++;{/php}
                                                                {/foreach}
                                                                <dd><a href="javascript:;" class="btn btn-sm btn-success btn-append" data-index="{$item_index}">{:lang('Append')}</a></dd>
                                                            </dl>
                                                            {/case}
                                                            {case editor_array}
                                                            <dl class="fieldlist editor_array" data-name="row[{$item.name}]">
                                                                <dd>
                                                                    <ins>{:lang('plugin.array_key')}</ins>
                                                                    <ins>{:lang('plugin.array_value')}</ins>
                                                                </dd>
                                                                {php}$item_index = 0;{/php}
                                                                {foreach $item.value as $key2=>$item2}
                                                                <dd class="form-inline">
                                                                    <input type="text" name="row[{$item.name}][{$item_index}][key]" form-verify="required" data-rule-msg="不能为空" class="form-control" value="{$key2}" size="10">
                                                                    <textarea name="row[{$item.name}][{$item_index}][value]" class="form-control hidden editor_array_lists" data-key="{$item_index}">{$item2|htmlentities}</textarea>
                                                                    <div id="content-{$item_index}"></div>
                                                                    <i class="iconfont icon-iconset0127 btn-remove"></i>
                                                                </dd>
                                                                {php}$item_index++;{/php}
                                                                {/foreach}
                                                                <dd><a href="javascript:;" class="btn btn-sm btn-success btn-append" data-index="{$item_index}">{:lang('Append')}</a></dd>
                                                            </dl>
                                                            {/case}
                                                            {case date}
                                                            <input type="text" name="row[{$item.name}]" value="{$item.value|htmlentities}" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-rule-msg="{$item.rule_msg}" form-verify="{$item.rule}"/>
                                                            {/case}
                                                            {case time}
                                                            <input type="text" name="row[{$item.name}]" value="{$item.value|htmlentities}" class="form-control datetimepicker" data-date-format="HH:mm:ss" data-rule-msg="{$item.rule_msg}" form-verify="{$item.rule}"/>
                                                            {/case}
                                                            {case datetime}
                                                            <input type="text" name="row[{$item.name}]" value="{$item.value|htmlentities}" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-rule-msg="{$item.rule_msg}" form-verify="{$item.rule}"/>
                                                            {/case}
                                                            {case number}
                                                            <input type="number" name="row[{$item.name}]" value="{$item.value|htmlentities}" class="form-control" data-rule-msg="{$item.rule_msg}" form-verify="{$item.rule}"/>
                                                            {/case}
                                                            {case checkbox}
                                                            {foreach name="item.content" item="vo"}
                                                            <label for="row[{$item.name}][]-{$key}"><input id="row[{$item.name}][]-{$key}" name="row[{$item.name}][]" type="checkbox" value="{$key}" data-rule-msg="{$item.rule_msg}" {in name="key" value="$item.value" }checked{/in} /> {$vo}</label>
                                                            {/foreach}
                                                            {/case}
                                                            {case radio}
                                                            {foreach name="item.content" item="vo"}
                                                            <label for="row[{$item.name}]-{$key}"><input id="row[{$item.name}]-{$key}" name="row[{$item.name}]" type="radio" value="{$key}" data-rule-msg="{$item.rule_msg}" {in name="key" value="$item.value" }checked{/in} /> {$vo}</label>
                                                            {/foreach}
                                                            {/case}
                                                            {case value="select" break="0"}{/case}
                                                            {case value="selects"}
                                                            <select name="row[{$item.name}]{$item.type=='selects'?'[]':''}" class="form-control selectpicker" data-rule-msg="{$item.rule_msg}" {$item.type=='selects'?'multiple':''}>
                                                                {foreach name="item.content" item="vo"}
                                                                <option value="{$key}" {in name="key" value="$item.value" }selected{/in}>{$vo}</option>
                                                                {/foreach}
                                                            </select>
                                                            {/case}
                                                            {case value="image" break="0"}{/case}
                                                            {case value="images"}
                                                            <div class="form-inline">
                                                                <input id="c-{$item.name}" class="form-control" size="35" name="row[{$item.name}]" type="text" value="{$item.value|htmlentities}" form-verify="{$item.rule}" data-rule-msg="{$item.rule_msg}">
                                                                <input type="file" class="hidden-input faupload" data-input-id="c-{$item.name}" accept="image/*" />
                                                                <span><button type="button" id="faupload-{$item.name}" class="btn btn-danger"><i class="fa fa-upload"></i> {:lang('public.upload')}</button></span>
                                                                <ul class="row list-inline faupload-preview" id="p-{$item.name}">
                                                                    {if !empty($item.value)}
                                                                    <li class="col-xs-3">
                                                                        <a class="thumbnail">
                                                                            <i class="iconfont icon-iconset0127 btn-remove2"></i>
                                                                            <img src="{$item.value|htmlentities}" class="img-responsive">
                                                                        </a>
                                                                    </li>
                                                                    {/if}
                                                                </ul>
                                                            </div>
                                                            {/case}
                                                            {case value="file" break="0"}{/case}
                                                            {case value="files"}
                                                            <div class="form-inline">
                                                                <input id="c-{$item.name}" class="form-control" size="35" name="row[{$item.name}]" type="text" value="{$item.value|htmlentities}" form-verify="{$item.rule}" data-rule-msg="{$item.rule_msg}">
                                                                <input type="file" class="hidden-input faupload" data-input-id="c-{$item.name}" />
                                                                <span><button type="button" id="faupload-{$item.name}" class="btn btn-danger"><i class="fa fa-upload"></i> {:lang('public.upload')}</button></span>
                                                            </div>
                                                            {/case}
                                                            {case bool}
                                                            <label for="row[{$item.name}]-yes"><input id="row[{$item.name}]-yes" name="row[{$item.name}]" type="radio" value="1" {$item.value?'checked':''} data-rule-msg="{$item.rule_msg}" /> {:lang('Yes')}</label>
                                                            <label for="row[{$item.name}]-no"><input id="row[{$item.name}]-no" name="row[{$item.name}]" type="radio" value="0" {$item.value?'':'checked'} data-rule-msg="{$item.rule_msg}" /> {:lang('No')}</label>
                                                            {/case}
                                                            {default /}{$item.value}
                                                            {/switch}
                                                        </div>
                                                    </div>
                                                </td>
                                            </tr>
                                            {/foreach}
                                            </tbody>
                                        </table>
                                    </div>
                                    <div class="form-group col-md-12 iframe-footer">
                                        <button type="button" class="btn btn-primary" id="plugin_config">{:lang('public.save')}</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </main>
    </div>
</div>
<script type="text/javascript" src="/static/admin/js/validation.js"></script>
<script type="text/javascript" src="/static/admin/layer/layer.js"></script>
<script type="text/javascript" src="/static/admin/js/common.js"></script>
<script>
    let IM_config = {
        custs_id: "{$custs['id']}",
        uploadimg: "{:apiUrl('api/Upload/img')}",
        ajaxupfile: "{:apiUrl('api/Upload/ajaxupfile')}",
        pluginConfig: "{:adminUrl('admin/Plugins/plugin_config',['name'=>$addon.info['name']])}"
    };
    let IM_toget_config = {
        unread:"{:apiUrl('api/Unread/index')}",
    };
    function HTMLDecode(text) {
        var temp = document.createElement("div");
        temp.innerHTML = text;
        var output = temp.innerText || temp.textContent;
        temp = null;
        return output;
    }
</script>
<script type="text/javascript" src="/static/admin/js/plugin.js"></script>
<script type="text/javascript">
    {foreach $addon.config as $item}
    {if $item.type == 'editor_array'}
    {php}$item_index = 0;{/php}
        {foreach $item.value as $key2=>$item2}
        const Editor_{$item_index} = new window.wangEditor('#content-{$item_index}');
        we_im_load_wangEditor(Editor_{$item_index});
        var html = $('#content-{$item_index}').siblings('textarea').val();
        Editor_{$item_index}.txt.html(HTMLDecode(html));
        {php}$item_index++;{/php}
            {/foreach}
                {/if}
                    {/foreach}
</script>
</body>
</html>